package com.lcxw.hxzbapi.controller.unioncontroller;

import com.lcxw.hxzbapi.entity.requestBean.GetUnionListReq;
import com.lcxw.hxzbapi.entity.requestBean.JoinUnionReq;
import com.lcxw.hxzbapi.entity.requestBean.RequestParamBasic;
import com.lcxw.hxzbapi.entity.requestBean.TurnUnionReq;
import com.lcxw.hxzbapi.entity.response.Response;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/union")
@Slf4j
public class UnionAppController {

    @Resource
    UnionMemberRealization unionMemberRealization;

    //申请加入工会接口
    @PostMapping("/join/apply")
    public Response joinUnionApply(@RequestBody JoinUnionReq joinUnionReq) {
        try {
            return unionMemberRealization.joinUnionApply(joinUnionReq);
        } catch (Exception e) {
            e.printStackTrace();
            return Response.dbFail(log, "查询数据库失败");
        }
    }

    //申请退出工会接口
    @PostMapping("/quit/apply")
    public Response quitUnionApply(@RequestBody JoinUnionReq quitUnionReq) {
        return unionMemberRealization.quitUnionApply(quitUnionReq);
    }

    //获取工会列表接口
    @PostMapping("/getList")
    public Response getUnionList(@RequestBody GetUnionListReq requestBody) {
        return unionMemberRealization.getUnionList(requestBody);
    }

    //获取我的工会信息接口
    @PostMapping("/getMine")
    public Response getMyUnionInfo(@RequestBody RequestParamBasic requestBody) {
        return unionMemberRealization.getMyUnionInfo(requestBody);
    }

    //转会申请
    @PostMapping("/turnUnion")
    public Response turnUnion(@RequestBody TurnUnionReq turnUnionReq) {
        return unionMemberRealization.turnUnionReq(turnUnionReq);
    }
}
